<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@page import="dao.NoteDao" import="model.NoteModel" import="util.JsonHelp" 
import="model.UsersModel" import="java.util.*" import="java.text.*" import="util.Replace"
 import="org.apache.commons.lang.StringEscapeUtils"%>    
<%
    	request.setCharacterEncoding("utf-8");

	String title = StringEscapeUtils.escapeHtml(Replace.replaceBlank(request.getParameter("title")));
    String content = StringEscapeUtils.escapeHtml(Replace.replaceBlank(request.getParameter("content")));

    int id = Integer.valueOf(request.getParameter("id"));
    Date date  = new Date();
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String showDate = format.format(date);


    String json;
    JsonHelp render = new JsonHelp();
    if((Integer)session.getAttribute("id")!=null){		
    		
    		NoteDao dao = new NoteDao();
    		int i = dao.update(title,content,showDate,id);
    		if(i>0){
    	json= "{\"status\":1,\"msg\":\"修改成功\"}";
    		}else{
    	json= "{\"status\":1,\"msg\":\"修改失败，未知错误！\"}";
    		}
    		 
    }else{
    	json= "{\"status\":0,\"msg\":\"修改失败，用户未登录！\"}";
    	
    }
    render.renderJson(response, json);
    %>